<template>
  <div class="five">
    <div class="top">{{ number }}</div>
    <div class="button">
      <el-button type="primary" size="mini" @click="start">开始</el-button>
      <el-button type="primary" size="mini" @click="stop">停止</el-button>
      <el-button type="primary" size="mini" @click="restart">复位</el-button>
    </div>
  </div>
</template>


<script>
export default {
  name: "Five",
  components: {},
  data() {
    return {
      number: 0,
      timer: null,
    };
  },
  methods: {
    start() {
      if (!this.timer) {
        this.timer = setInterval(() => {
          this.number += 1;
        }, 1000);
      }
    },
    stop() {
      clearInterval(this.timer);
      this.timer = null;
    },
    restart() {
      this.number = 0;
      clearInterval(this.timer);
      this.timer = null;
    },
  },
};
</script>


<style scoped>
.five {
  width: 500px;
  height: 500px;
  background-color: #ccc2c2;
  border-radius: 50%;
  overflow: hidden;
  margin-left: 18%;
}
.top {
  width: 100px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  background-color: #8ab0da;
  margin-left: 250px;
  transform: translate(-50%);
  margin-top: 40%;
}
.button {
  margin-left: 50%;
  transform: translate(-35%);
  margin-top: 10%;
}
</style>